package ex.algorithms.sorting;

import ex.algorithms.heap.Heap;
import ex.util.CommonUtil;

public class HeapSort {
	public static void sortIncreasing(int[] input) {
		if(input == null || input.length < 2)
			return;
		
		Heap.buildMaxHeap(input);
		
		int maxIndex = input.length - 1;
		while(maxIndex > 0) {
			CommonUtil.swap(input, 0, maxIndex);
			maxIndex --;
			Heap.maxHeapify(input, 1, maxIndex + 1);
		}
	}
	
	
}
